﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity.EntityFramework;
using Sino.Tms.Primitives;
using Sino.CapacityCloud.WebApi;
using System.ComponentModel.DataAnnotations.Schema;

namespace Sino.CapacityCloud.Repositories.Models
{

    public class ApplicationUser
        : IdentityUser
    {

        public string CarId { get; set; }

        public string Address { get; set; }

        public string RealName { get; set; }

        public string AvatarKey { get; set; }

        public string CertificatePhotoKey { get; set; }

        public CertificationStatus CertificatePhotoCertificationState { get; set; }

        public string IdentityCardKey { get; set; }

        public CertificationStatus IdentityCardCertificationState { get; set; }

        public string DrivingLicenseKey { get; set; }

        public CertificationStatus DrivingLicenseKeyCertificationState { get; set; }

        public string Profile { get; set; }

        public string Token { get; set; }

        public string DeviceToken { get; set; }

        public long FailureTime { get; set; }

        public DateTime CertificationTime { get; set; }

        public DateTime CertificationApplicationTime { get; set; }

        [NotMapped]
        public CertificationStatus OverallCertificateStatus { get; set; }

        public CarriageType CarriageType { get; set; }

        public virtual ICollection<UserPointRecord> Points { get; set; }

        public virtual ICollection<BankCard> BankCards { get; set; }

        public virtual ICollection<CommonTransportLinkage> CommonTransportLinkages { get; set; }

        public virtual ICollection<FavouriteTransportLinkage> FavouriteTransportLinkages { get; set; }

        public virtual Car Car { get; set; }

        public ApplicationUser()
            : base()
        {
            this.Initialize();
        }

        public ApplicationUser(string userName)
           : base(userName)
        {
            this.Initialize();
        }

        protected virtual void Initialize()
        {
            this.Id = Guid.NewGuid().ToString();
            this.Points = new List<UserPointRecord>();
            this.BankCards = new List<BankCard>();
            this.CommonTransportLinkages = new List<CommonTransportLinkage>();
            this.FavouriteTransportLinkages = new List<FavouriteTransportLinkage>();
        }

    }

}